package com.sky.mapper;

import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {


    List<SetmealVO> getPage(SetmealPageQueryDTO queryDTO);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into setmeal(category_id, name, price, status, description, image)\n" +
            "values (#{categoryId}, #{name}, #{price}, #{status}, #{description}, #{image})")
    void save(Setmeal setmeal);

    @Select("select category_id, name, price, status, description, image from setmeal where id = #{setmealId}")
    Setmeal getById(Long setmealId);



    List<Setmeal> getList(SetmealPageQueryDTO setmealPageQueryDTO);

    @Select("select * from setmeal where category_id=#{categoryId}")
    List<Setmeal> getListBycategoryId(Long categoryId);

    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    List<Long> getSetmealIdsByDishIds(Long[] dishIds);

    void update(Setmeal setmeal);


    void insert(Setmeal setmeal);

    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);


    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long setmealId);


    SetmealVO getByIdWithDish(Long id);


    List<Setmeal> list(Setmeal setmeal);


    Integer countByMap(Map map);

    @Select("select * from setmeal where id=#{id}")
    Setmeal getBySetemealId(Long id);

    @Select("select count(*) from setmeal where status = 1")
    int launchedCount();

    @Select("select count(*) from setmeal where status = 0")
    int discontinuedCount();
}
